@charset "utf-8";

// 定义range的基础构造
@mixin _range {
    @include flexbox;
    line-height: 1;
    > input[type="range"] {
        @include appearance(none);
        @include flex;
        overflow: hidden;
        height: .28rem;
        @include gradient(linear, top, map-get($range, outer-bgcolor), map-get($range, outer-bgcolor));
        background-size: 100% .04rem;
        background-repeat: no-repeat;
        background-position: center;
        &::-webkit-slider-thumb {
            @include appearance(none);
            @include square(.2rem);
            position: relative;
            border: 0;
            @include border-radius(50%);
            box-shadow: 0 0 2px rgba(0, 0, 0, .5), 1px 1px 5px rgba(0, 0, 0, .25);
            background-color: map-get($range, ball-color);
            &::before {
                position: absolute;
                top: .08rem;
                left: -2001px;
                width: 2000px;
                height: .04rem;
                background-color: map-get($range, inner-bgcolor);
                content: "\0020";
            }
        }
        &:disabled {
            opacity: .4;
        }
    }
    > .yo-ico {
        font-size: .2rem;
        &:first-child {
            margin-right: .1rem;
        }
        &:last-child {
            margin-left: .1rem;
        }
    }
}

/**
 * @module element
 * @method yo-range
 * @version 1.0.0
 * @description 构造区间选择的自定义使用方法（安卓4.3及以下有点问题）
 * @demo http://doyoe.github.io/Yo/demo/element/yo-range.html
 * @param {String} $name 定义扩展名称 <1.0.0>
 * @param {Color} $inner-bgcolor 已选择区域滑条色 <1.0.0>
 * @param {Color} $outer-bgcolor 未选择区域滑条色 <1.0.0>
 * @param {Color} $ball-color 滑块色 <1.0.0>
 */

@mixin yo-range(
    $name: default,
    $inner-bgcolor: default,
    $outer-bgcolor: default,
    $ball-color: default) {
    // 区别是否新增实例还是修改本身
    $name: if($name == default, "", "-#{$name}");
    // 如果值为default，则取config的定义
    @if $inner-bgcolor == default {
        $inner-bgcolor: map-get($range, inner-bgcolor);
    }
    @if $outer-bgcolor == default {
        $outer-bgcolor: map-get($range, outer-bgcolor);
    }
    @if $ball-color == default {
        $ball-color: map-get($range, ball-color);
    }
    .yo-range#{$name} {
        > input[type="range"] {
            @if $outer-bgcolor != map-get($range, outer-bgcolor) {
                @include gradient(linear, top, $outer-bgcolor, $outer-bgcolor);
            }
            &::-webkit-slider-thumb {
                @if $ball-color != map-get($range, ball-color) {
                    background-color: $ball-color;
                }
                &::before {
                    @if $inner-bgcolor != map-get($range, inner-bgcolor) {
                        background: $inner-bgcolor;
                    }
                }
            }
        }
        // 增量扩展
        @content;
    }
}

// 调用本文件时载入按钮基础构造
.yo-range {
    @include _range;
}